/**
 * @Title: LeaveOutAdapter.java
 * @Package: com.jason.bluetooth.fingerprint.adapter
 * @Descripton: TODO
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2014年11月9日23:32:04
 * @Version: V1.0
 */
package com.jason.platform.supervision.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.hzlj.supervision.changsha.R;
import com.jason.platform.supervision.beans.WorkingVisitBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: InterviewAdapter
 * @Description: 工作走访适配器
 * @Author: Jason.Zhang zhangyujn1989ok@gmail.com
 * @Date: 2015-8-8 09:14:30
 */
public class InterviewAdapter extends BaseAdapter {

	private static final String TAG = InterviewAdapter.class.getSimpleName();

	private Context mContext;
	private LayoutInflater mLayoutInflater;
	private List<WorkingVisitBean> mDatas = new ArrayList<WorkingVisitBean>();

	public InterviewAdapter(Context context) {
		super();
		this.mContext = context;
		this.mLayoutInflater = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		this.mDatas = new ArrayList<WorkingVisitBean>();
	}

	@Override
	public int getCount() {
		return mDatas.size();
	}

	@Override
	public Object getItem(int position) {
		return mDatas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	public void addAll(List<WorkingVisitBean> datas) {
		this.mDatas = datas;
		if (mDatas == null){
			mDatas = new ArrayList<WorkingVisitBean>();
		}
		notifyDataSetChanged();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder holder = null;
		if (convertView == null) {
			convertView = mLayoutInflater.inflate(
					R.layout.adapter_interview, null);
			holder = new Holder();
			holder.mNameTextView = (TextView) convertView
					.findViewById(R.id.interview_name);
			holder.mTimeTextView = (TextView) convertView
					.findViewById(R.id.interview_time);
			holder.mManagerTextView = (TextView) convertView
					.findViewById(R.id.interview_manager);
			convertView.setTag(holder);
		} else {
			holder = (Holder) convertView.getTag();
		}
		final WorkingVisitBean bean = (WorkingVisitBean) getItem(position);
		if (bean != null){
			holder.mNameTextView.setText(bean.getAdjustName());
			holder.mTimeTextView.setText(bean.getInterViewTime());
			holder.mManagerTextView.setText(bean.getUserName());
		}
		return convertView;
	}

	class Holder {
		TextView mNameTextView;
		TextView mTimeTextView;
		TextView mManagerTextView;
	}

}
